Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] error handling #246

Closed
wants to merge 2 commits into from
Closed

Conversation

jscheffner
Copy link

@jscheffner jscheffner commented Nov 18, 2018

Hey, I replaced all the logged warnings with emitting an event. Also, unknown TCP options no longer result in a thrown error but also in an emitted warning. That should fix #240 and fix #183. I might add some tests, so please don't merge it yet.

This is a breaking change, so it should be published with the next major version. Before doing so it might be a good idea to agree on a general concept of handling errors. If decoding a higher level protocol fails, should the complete decoding fail or just leave part of it encoded and emit a warning? For example, the DNS decoder does throw some errors. Should lower level protocols handle these?

emit warning for unknown TCP options instead of throwing error
@roccomuso
Copy link
Collaborator

ok thanks

@jscheffner
Copy link
Author

jscheffner commented Dec 6, 2018

I didn't manage to write tests since for this I would need to create encoded TCP packets with unknown options and I don't have the time to look into how to do that. There were no tests for error handling before, so this PR shouldn't decrease the test coverage.

This PR makes error handling more consistent but I'm not sure if it's actually such a good idea not to throw an error if an unknown option or an invalid option length forces the decoder to stop decoding the rest of the options. I guess there are use cases where users actually need to know if an option is set and they might need to know if the reason why it isn't is that the decoder stopped decoding at some point.

@jscheffner
Copy link
Author

Maybe the options object should at least have some property that signals if all options were decoded?

@jscheffner jscheffner closed this May 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Silence console.log decode/tcp.js throws error on valid TCP option kind numbers
2 participants